<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
	<title>部门数据权限</title>
	<%@ include file="/common/meta.jsp" %>
    <%@ include file="/common/import.jsp" %>
	<%@ include file="uct-import.jsp" %>
	

		<script>
		var userId="${userId}";
		$(function(){
			$('#deptList').treegrid({
				title:'',
				//iconCls:'icon-ok',
				fitColumns: true,
				nowrap: true,
				rownumbers: true,
				animate:true,
				collapsible:false,
				singleSelect:false,
				url:'${ctx}/uct/core/user-right-dept!data.action?userId='+userId , 
				idField:'deptId',
				treeField:'deptCname',				
				frozenColumns:[[
					
	                {title:'部门名称',field:'deptCname',width:250,
		                formatter:function(value){
		                	return '<span style="color:red">'+value+'</span>';
		                }
	                }
	                
				]],
				columns:[[
					{title:'部门代码',field:'deptEname',width:200},
					{title:'所属机构标识',field:'orgEname',width:200},
									
					{title:'操作',field:'hasGive',width:50,
						formatter:function(value,row){
						//alert(row.id);
								if(value=="T"){
									return '<img id="hasGive_'+row.deptId+'" name="hasGiveCheck" src="${ctx}/js/easyui/themes/default/images/tree_dnd_yes.png"/>';
								}else{
									return '<img id="hasGive_'+row.deptId+'" name="hasGiveCheck" src="${ctx}/js/easyui/themes/default/images/tree_dnd_no.png"/>';
								}
						}
					}
					/**,*/
				]],
				onDblClickRow:function(row){  
                    //级联选择  
                    $(this).treegrid("cascadeCheck",{  
                        id:row.deptId, //节点ID  
                        imgsrc:"${ctx}/js/easyui/themes/default/images/",
                        deepCascade:true //深度级联  
                    });  
                }  
			});
		});
		
		function giveActs(deptId,flag,tmppic){
			var url = "${ctx}/uct/core/user-data-give.action?flag=add&giveType=dept&objId="+deptId+"&userId="+userId;
			if("del" == flag){
				url = "${ctx}/uct/core/user-data-give.action?flag=del&giveType=dept&objId="+deptId+"&userId="+userId;
			}
			$.ajax({
				type: "post",
				url: url,
				async:false,
				success: function(data, textStatus){
					$("#hasGive_"+deptId).attr("src",tmppic);
				}
			});
         }

		function expandAll(){
			var node = $('#deptList').treegrid('getSelected');
			if (node){
				$('#deptList').treegrid('expandAll', node.code);
			} else {
				$('#deptList').treegrid('expandAll');
			}
		}
	</script>
</head>

<body>
<table id="deptList"></table>	
</body>
</html>